Skip to content

added optimized auto completion script#340

Open
sker65 wants to merge 3 commits intomainfrom
optimized-auto-completion
Open

added optimized auto completion script#340
sker65 wants to merge 3 commits intomainfrom
optimized-auto-completion

Conversation

@sker65
Copy link
Contributor

@sker65 sker65 commented Jan 19, 2026

Greptile Summary

Added optimized zsh completion script that implements context-aware caching and intelligent fallback to file completion. The script caches completions per test target and subcommand, with automatic background refresh after 1 minute, significantly improving tab completion performance.

  • Created new completion script at scripts/octomind.zsh with caching mechanism
  • Implemented context-sensitive caching based on testTargetId from config file
  • Added fallback to standard file completion when no CLI completions available
  • Background cache refresh prevents blocking on stale cache

Confidence Score: 4/5

  • This PR is safe to merge with one syntax fix required
  • The implementation is well-structured with clear caching logic and good fallback behavior. However, there is a syntax error in the grep pattern on line 41 (missing closing quote) that will cause the context_id extraction to fail. Once fixed, the script should work correctly.
  • Pay attention to line 41 in scripts/octomind.zsh - the regex pattern needs a closing quote

Important Files Changed

Filename Overview
scripts/octomind.zsh Added optimized zsh completion script with context-aware caching and intelligent fallback to file completion

Sequence Diagram

sequenceDiagram
    participant User
    participant Shell as Zsh Shell
    participant Script as _fast_octomind_completion
    participant Cache as Cache File
    participant CLI as octomind CLI

    User->>Shell: Press TAB for completion
    Shell->>Script: Invoke completion function
    Script->>Script: Extract context_id from config
    Script->>Script: Determine cache file path
    
    alt Cache exists and is valid
        Script->>Cache: Read cached completions
        Cache-->>Script: Return completions
        Script->>Shell: Display completions
        
        alt Cache older than 1 minute
            Script->>CLI: Refresh cache in background
            CLI-->>Cache: Update cache file
        end
    else No cache or empty cache
        Script->>CLI: Request completions (blocking)
        CLI-->>Script: Return completions
        Script->>Cache: Write completions to cache
        Script->>Shell: Display completions
    end
    
    alt No CLI completions available
        Script->>Shell: Fallback to file completion
    end
    
    Shell-->>User: Show completion options
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>

local config_file="$HOME/.config/octomind.json"
local context_id="default"
[[ -f "$config_file" ]] && context_id=$(grep -o '"testTargetId": "[^"]*"' "$config_file" | cut -d'"' -f4)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the grep could yield empty or multiple, maybe we should safeguard?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants